package com.running.base.run.util;

import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.ProceedingJoinPoint;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ClassUtil {
	
	private static final Logger LOGGER = LoggerFactory.getLogger(ClassUtil.class);
	
	public static String createMetricName(ProceedingJoinPoint jp, String defaultMetricName) {
        try {
            if (!StringUtils.isEmpty(defaultMetricName)) {
                return defaultMetricName;
            } else {
                return jp.getTarget().getClass().getSimpleName() + "." + jp.getSignature().getName();
            }
        } catch (Exception e) {
            LOGGER.error("ClassUtil.createMetricName exception: ", e);
            return "unknown.metric";
        }
    }
}
